<%--
  Created by IntelliJ IDEA.
  User: BluceYoung
  Date: 2020/12/4
  Time: 15:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:include page="../temp/index_head.jsp">
    <jsp:param name="title" value="个人资料修改"/>
    <jsp:param name="needSwitch" value="true"/>
</jsp:include>
<div class="col-md-12 col-sm-12 col-xs-12">
    <div class="x_panel">
        <div class="x_title">
            <h2>个人资料修改 <small>different form elements</small></h2>
            <div class="clearfix"></div>
        </div>
        <div class="x_content">
            <br>
            <form action="${pageContext.request.contextPath}/user/edit.html" method="post" id="demo-form2"  class="form-horizontal form-label-left" >
                <div class="form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="login-mail">登录邮箱
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                        <input type="text" id="login-mail"   value="${user.loginMail}" disabled class="form-control col-md-7 col-xs-12">
                        <input type="hidden" name="loginMail" value="${user.loginMail}"/>
                        <%--为了保存时回传用户编号--%>
                        <input type="hidden" name="id" value="${user.id}" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="nick-name">昵称 <span class="required">*</span>
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                        <input type="text" id="nick-name" value="${user.nickName}" name="nickName" required="required" class="form-control col-md-7 col-xs-12">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="true-name">真实姓名 <span class="required">*</span>
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                        <input type="text" id="true-name" name="trueName" value="${user.trueName}" required="required" class="form-control col-md-7 col-xs-12">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="phone">电话 <span class="required">*</span>
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                        <input type="text" id="phone" name="phone" maxlength="11" value="${user.phone}" required  class="form-control col-md-7 col-xs-12">
                    </div>
                </div>
                <div class="form-group">
                    <label for="id-card" class="control-label col-md-3 col-sm-3 col-xs-12">身份证号<span class="required">*</span></label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                        <input id="id-card" value="${user.idCard}" maxlength="18" class="form-control col-md-7 col-xs-12" type="text" required name="idCard">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12">性别</label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                        <input type="checkbox" id="chkSex" checked />
                        <input id="hidSex" type="hidden" name="sex" value="男" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="qq-code">QQ号
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                        <input id="qq-code" name="qqCode" value="${user.qqCode}" class="form-control col-md-7 col-xs-12"  type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="wechat-code">微信号
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                        <input id="wechat-code" name="wechatCode" value="${user.wechatCode}" class="form-control col-md-7 col-xs-12"  type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="signature">个性签名
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                        <textarea id="signature" name="signature" class="form-control col-md-7 col-xs-12">${user.signature}</textarea>
                    </div>
                </div>
                <div class="ln_solid"></div>
                <div class="form-group">
                    <div class="col-md-6 col-sm-6 col-xs-12 col-sm-offset-3 col-md-offset-3">
                        <button type="submit" class="btn btn-primary">保存</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<jsp:include page="../temp/index_foot.jsp">
    <jsp:param name="needSwitch" value="true"/>
</jsp:include>
<script type="text/javascript">
    $("#chkSex").bootstrapSwitch({
        onText:"男",
        offText:"女",
        onColor:"primary",
        offColor:"danger",
        onSwitchChange:function(event, state){
            $("#hidSex").val(state?"男":"女")
        }
    });
    var sex="${user.sex}";
    if(sex.length>0){//需要设置一个性别
        $("#chkSex").bootstrapSwitch('state', sex=="男"?true:false);
    }else{//需要设置一个默认值，男
        $("#chkSex").bootstrapSwitch('state', true);
    }


    var msg="${msg}";
    if(msg.length>0){//保存后的提交结果
        alert(msg);
        if(msg.indexOf("成功")>=0){
            window.location="${pageContext.request.contextPath}/user/profile/"
        }
    }
</script>
